/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cardgame.game.monsters;

import cardgame.game.*;
import cardgame.game.events.*;

/**
 *
 * @author Carl
 */
public class TolVir extends MonsterCard{

    public TolVir(){
        description = new Description("Tol'vir", "When this card is summoned, heal all allies for 2 and damage all enemies for 2.");
        manaTypes = new Mana[]{Mana.WHITE};
        summonCost = new Cost(new ManaAmount(Mana.WHITE, 7), 0, false);
        attackDamage = 7;
        setLifepoints(7);
    }

    @Override
    public void onSummon(){
        super.onSummon();
        applySummonEffect(owner);
        applySummonEffect(owner.getEnemy());
    }
    
    private void applySummonEffect(Player player){
        int lifepoints = ((player == owner)?2:-2);
        game.triggerEvent(new AddPlayerLifepointsEvent(player, lifepoints));
        Cards monsters = player.getMonsters();
        for(int i=0;i<monsters.size();i++){
            MonsterCard monsterCard = (MonsterCard) monsters.get(i);
            if(game.triggerEvent(new AddMonsterCurrentLifepointsEvent(monsterCard, lifepoints))){
                if(monsterCard.getCardPosition().getZone() == CardPosition.Zone.GRAVEYARD){
                    i--;
                }
            }
        }
    }
}
